package com.yanxu.bak;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2025-06-04-2025
 * @Description: 这里用一句话描述这个类的作用
 */
public class Listener {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket(8888);
        byte[] buf = new byte[1024];
        DatagramPacket datagramPacket = new DatagramPacket(buf, buf.length);
        datagramSocket.receive(datagramPacket);

        String msg = new String(buf, 0, datagramPacket.getLength());
        System.out.println("收到的消息:" + msg);
    }
}